package com.yylending.las.lending.video;

import com.yyfax.common.CLog;
import com.yyfax.infrastructure.eventbus.EventAgent;
import com.yyfax.infrastructure.mvp.Model;
import com.yyfax.infrastructure.network.NetworkHelper;
import com.yyfax.infrastructure.network.entity.BaseResultEntity;
import com.yyfax.infrastructure.network.entity.EmptyEntity;
import com.yylending.las.Global;
import retrofit2.http.Body;
import retrofit2.http.Header;
import retrofit2.http.POST;
import rx.Observable;

/**
 * Created by HenryZhang on 2017/7/12.<br>
 * Copyright © 2017 www.yylending.com. All Rights Reserved.<br><br>
 */
public class SignModel extends Model {
	private static final String TAG = "SignModel";

	@Override
	public Observable getObservable(Object params, int functionalCode) {
		Service service = (Service) NetworkHelper.createService(Service.class);
		return service.getAnyChatSign(Global.LOGIN_TOKEN, new EmptyEntity());
	}

	@Override
	public void onNext(Object entity) {
		CLog.i(TAG, "onNext: " + entity.toString());
		AnyChatSign sign = cast(entity);
		EventAgent.post(sign);
	}

	private interface Service {
		@POST("server/anyChat/getAnyChatSign")
		Observable<AnyChatSign> getAnyChatSign(@Header("token") String token, @Body EmptyEntity params);
	}

	static class AnyChatSign extends BaseResultEntity<Sign> {
	}

	public static class Sign {
		/**时间戳*/
		public String timestamp;
		/**私钥*/
		public String sign;
		/**面签申请编号*/
		public String taskNo;
	}
}
